// 2.字符串的压缩 “aaabbcaaddd”  -->a3b2c1a2d3
package main

import (
	"fmt"
)

func main() {
	var str string
	fmt.Println("请输入一串字符串：")
	fmt.Scan(&str)
	var str1 string
	char := ' '
	count := 0
	for _, v := range str {
		if v == char {
			count++
		} else {
			if count > 0 {
				str1 = str1 + string(char) + fmt.Sprint(count)
			}
			char = v
			count = 1
		}
	}
	str1 = str1 + string(char) + fmt.Sprint(count)
	fmt.Println(str1)
}
